<html>
<head>
    <title>登录</title>
</head>
<body>
<form action="ActionServlet" method="post">
    <table border="0px" align="center">
        <tr>
            <td>账号：<input type="text" id="name" name="username"/></td>
        </tr>

        <tr>
            <td>密码：<input type="text" id="pwd" name="password"/></td>
        </tr>
        <tr>
            <td><input type="button" value="登录" id="sub"/></td>
        </tr>
    </table>
</form>
</body>
</html>
<script src="juqery/jquery-3.7.1.js">
</script>

<script>
    $(function (){

        $("#sub").click(function (){
            var name = $("#name").val();
            var pwd = $("#pwd").val();
            $.ajax({
                url:"ActionServlet",
                type:"post",
                data:{
                    "username":name,
                    "password":pwd,
                    "op":"login"
                },
                success:function (data){

                    console.log(data);
                    if(data == "ok"){
                        window.location.href = "index.jsp";
                    }else{
                        alert("账号或密码错误");
                    }
                }
            })
        })
    })
</script>